/***
Input Balance sheet data
Date: July 2022
Author: IM

This file:
- import and clean brn data
- restrict to brn files
- compute annual growth rates rate of VA and other variables

Input:
- brn data in $brnpath
- labelbrn.do in $dofile

Output:
- $commonpath/brn_wof_$firstyearbrn$lastyearbrn	
- $brnpath/import_brn$firstyearbrn$lastyearbrn.txt (log file)

***/

* Import and clean balance sheet data
do "$dopath/01_1_1_balancesheet_cleaning.do"

* Compute growth rate, outlier growth rates and check whether outlier growth rates are concentrated during the period around the two breaks (2001 and 2008)
global datagrowth "$commonpath/brn_wof_$firstyearbrn$lastyearbrn"
do "$dopath/01_1_2_balancesheet_cleaning_growth_rates.do"


* Keeps non-missing growth rates
use "$datagrowth", clear
drop if gr_vabcf==.
sort siren year
egen cobs=count(gr_vabcf), by(siren)
drop if cobs<2
drop cobs
bys year: egen tot=sum(lag_vabcf)
g w_f=lag_vabcf/tot
drop tot
save "$datapath/brn_$firstyearbrn$lastyearbrn", replace

